<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>.::IFConnect::.</title>
        <link href="../styles/mainadmin.css" type="text/css" rel="stylesheet" media="all" />      
    </h:head>
    <h:body>

        <div id="cabecalho">
            <a href="principalAdmin.xhtml" alt="Administração" title="Voltar a página principal de administração"><img src="../images/topadmin.png" width="700" height="100" alt="Área Administrativa" /></a>
            <br />
            <div id="logincontrol">
                <h:panelGrid columns="2">
                    <h:outputText value="Bem-vindo #{usuariologin.usuario.nome} #{usuariologin.usuario.sobrenome}  " />
                    <h:form>
                        <h:commandLink value="Logoff" action="#{usuariologin.logout()}"/>
                    </h:form>
                </h:panelGrid>
            </div>
        </div>
        <div id="estrutura">
            <div id="conteudo">

                <h2>Painel de administração</h2>

                <h3>Gerenciar Professores</h3>
                <h:form id="form">

                    <p:growl/>

                    <p:dataTable id="users" value="#{gerenciarProfessorMB.listaProfessores}" var="professor" tableStyle="width:100%">
                        <p:column headerText="Id" style="">  
                            <h:outputText value="#{professor.id}" />  
                        </p:column>

                        <p:column headerText="Nome" style="">  
                            <h:outputText value="#{professor.nome} #{cadastro.professor}" />  
                        </p:column>

                        <p:column headerText="Matricula" style="">  
                            <h:outputText value="#{professor.matricula}" />  
                        </p:column>

                        <p:column headerText="Data de Nascimento" style="">  
                            <h:outputText value="#{professor.dataNascimento}" >
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>
                        </p:column>

                        <p:column style="width:40px">  

                            <p:commandButton id="selectButton" update=":form:display" oncomplete="userDialog.show()" icon="ui-icon-locked" title="View">  
                                <f:setPropertyActionListener value="#{professor}" target="#{gerenciarProfessorMB.usuarioSelecionado}" />  
                            </p:commandButton>  

                        </p:column>
                    </p:dataTable>

                    <p:dialog header="Gereciar Professor" widgetVar="userDialog" resizable="false" id="userDlg"  
                              showEffect="fade" hideEffect="explode" modal="true">  

                        <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  

                            <h:outputText value="Nome Completo:"/>
                            <h:outputText value="#{gerenciarProfessorMB.usuarioSelecionado.nome} #{gerenciarProfessorMB.usuarioSelecionado.sobrenome}"/>

                            <h:outputText value="Data de Nascimento:"/>
                            <h:outputText value="#{gerenciarProfessorMB.usuarioSelecionado.dataNascimento}" >
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>

                            <h:outputText value="Matricula:"/>
                            <h:outputText value="#{gerenciarProfessorMB.usuarioSelecionado.matricula}"/>

                            <h:outputText value="Email:"/>
                            <h:outputText value="#{gerenciarProfessorMB.usuarioSelecionado.email}"/>

                            <h:outputText value="Disciplinas:"/>
                            <p:dataList value="#{gerenciarProfessorMB.disciplinasProfessor}" var="disciplina" >  
                                #{disciplina.nome}
                            </p:dataList>
                            
                            <p:separator/>
                            <h:outputText value=""/>
                            
                            <h:outputText value="CADASTRAR/ATUALIZAR DISCIPLINAS:"/>
                            <h:outputText value=""/>
                            
                            <p:selectCheckboxMenu value="#{gerenciarProfessorMB.disciplinasSelecionadas}" label="Disciplinas" filter="true" filterMatchMode="startsWith">  
                                <f:selectItems value="#{gerenciarProfessorMB.disciplinas}" var="disciplina" itemLabel="#{disciplina}" itemValue="#{disciplina.id}" />  
                            </p:selectCheckboxMenu>
                            <h:outputText value=""/>

                            <p:commandButton value="Enviar" update="form" action="#{gerenciarProfessorMB.atualizarDisciplinasProfessor()}" icon="ui-icon-circle-check" oncomplete="userDialog.hide();" />


                        </h:panelGrid>  

                    </p:dialog>  

                </h:form>

            </div>
        </div>
    </h:body>
</html>